﻿using UnityEngine;
using System.Collections;

public class GiroRotateGravity : Giro 
{
    public bool constGravityPower;

    float firstGravityPower;

    void Start()
    {
        base.Start();
        firstGravityPower = Physics2D.gravity.magnitude;
    }

	void FixedUpdate () 
    {
        base.FixedUpdate();
        RotateGravity(GetAngel());
	}

    void RotateGravity(float angel)
    {
        float gravityPower = constGravityPower ? firstGravityPower : GetAcceleration().magnitude * speed;
        Vector2 gravityDirection = GetDirection();
        gravityDirection *= gravityPower;
        Physics2D.gravity = gravityDirection;
    }

}
